import { defineComponent } from 'vue';

import FilterLayout from './filter-layout.jsx';
import { useOperationProps } from './use-col-filter.js';
import TSelect from 't/basic/select';
export default defineComponent({
  name: 'TDataGridColFilterSelect',
  props: {
    ...useOperationProps,
  },
  emits: ['update:operation', 'change'],

  setup(props, { attrs, emit, expose, slots }) {
    const filterOperations = ['='];

    const operation = toRef(props.operation);

    provide('operation', operation);

    watchEffect(() => {
      emit('update:operation', operation.value);
      emit('change');
    });

    const options = [
      { label: 'BMW', value: true },
      { label: 'Samsung Phone', value: false },
    ];

    return () => {
      return (
        <FilterLayout filterOperations={filterOperations}>
          <TSelect
            filled
            v-model={operation.value.filterValue}
            options={options}
          />
        </FilterLayout>
      );
    };
  },
});
